home *** CD-ROM | disk | FTP | other *** search
/ Freelog 112 / FreelogNo112-NovembreDecembre2012.iso / Jeu / deadlyrace / deadlyrace_setup.exe / {app} / Data / Scripts / exit.lua < prev    next >
Encoding:
Text File  |  2010-05-23  |  1.7 KB  |  90 lines

  1. local script = globalObject;
  2.  
  3. local interface;
  4. local commandMap = {};
  5.  
  6. local function ExecuteCommands()
  7.     while(SetNextCommand(script))
  8.     do
  9.         local command = GetCurrentCommand(script);
  10.         if (commandMap[command])
  11.         then
  12.             commandMap[command]();
  13.         end
  14.     end
  15. end
  16.  
  17. local function Button()
  18.     local name = GetCurrentParams(script);
  19.     if ("no" == name)
  20.     then
  21.         LockButton(interface, "no");
  22.         SendCommandByName("main", "exit_interface", "");
  23.         SetTemp(0);
  24.         SetCamera(true);
  25.     elseif("yes" == name)
  26.     then
  27.         SetTemp(1);
  28.         SetCamera(false);
  29.         LockButton(interface, "yes");
  30.         SendCommandByName("main", "player_exit", "");
  31.         SendCommandByName("jeep", "game_over", "");
  32.         SetLevelStarted(false);
  33.     end
  34. end
  35.  
  36. local function AddObject()
  37.     local obj = GetCurrentParams(script);
  38.     interface = StringToPointer(obj);
  39.     SetTemp(0);
  40.     SetCamera(true);
  41.     
  42.     UnlockButton(interface, "yes");
  43.     UnlockButton(interface, "no");
  44. end
  45.  
  46. local function DeleteObject()
  47.     Release(interface);
  48.     StopScript(script);
  49.     SetTemp(1);
  50.     SetCamera(false);
  51.     interface = nil;
  52. end
  53.  
  54. local function ReleaseAll()
  55.     Release(interface);
  56.     interface = nil;
  57. end
  58.  
  59. local function MenuUp()
  60.     IMenuRight();
  61. end
  62.  
  63. local function MenuDown()
  64.     IMenuLeft();
  65. end
  66.  
  67. local function MenuLeft()
  68.     IMenuLeft();
  69. end
  70.  
  71. local function MenuRight()
  72.     IMenuRight();
  73. end
  74.  
  75. commandMap["release_all"] = ReleaseAll;
  76. commandMap["add_object"] = AddObject;
  77. commandMap["delete_object"] = DeleteObject;
  78. commandMap["button"] = Button; 
  79. commandMap["menu_up"] = MenuUp;
  80. commandMap["menu_down"] = MenuDown;
  81. commandMap["menu_left"] = MenuLeft;
  82. commandMap["menu_right"] = MenuRight;
  83.  
  84. while(true)
  85. do
  86.     ExecuteCommands();
  87.     UpdateInterface(interface);
  88.     Update();
  89. end
  90.